package com.thread.oop;

public class Machine8 extends Thread {

	private static StringBuffer logBuffer=new StringBuffer();
	private static int count=0;
	
	public void run(){
		for(int a=0; a<20;a++){
			logBuffer.append(currentThread().getName() + ":" + a + " ");
			if(++count % 10 ==0) logBuffer.append("\n");
			
			try {
				sleep(100);
			} catch (InterruptedException e) {
				throw new RuntimeException(e);
			}
		}
	}
	public static void main(String[] args) throws Exception {
		Machine8 machine1 = new Machine8();
		Machine8 machine2 = new Machine8();
		machine1.setName("m1");
		machine2.setName("m2");
		machine1.start();
		machine2.start();
		
		Thread.sleep(2000);
		System.out.println(logBuffer);

	}
}
